home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-03
/
qbasicpg.zip
/
GETMID.BAS
< prev
next >
Wrap
BASIC Source File
|
1989-08-31
|
1KB
|
39 lines
' GETMID.BAS
' This program demonstrates the MID$ function.
CLS
alphabet$ = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ' declare test string
PRINT "How many characters (from left to right) in the following"
PRINT "string would you like to display?"
PRINT
PRINT alphabet$ ' display test string
PRINT
' get from user number of characters to be displayed
DO ' loop until number is in proper range (1 through 26)
INPUT " Number (1-26): ", numToDisplay%
LOOP WHILE (numToDisplay% < 1) OR (numToDisplay% > 26)
PRINT ' get starting number...
PRINT "What character would you like to start with?"
PRINT
DO ' in proper range
INPUT " Starting number (1-26): ", start%
LOOP WHILE (start% < 1) OR (start% > 26)
PRINT ' get characters
midChar$ = MID$(alphabet$, start%, numToDisplay%)
' compare requested characters with actual characters retrieved
' and print an appropriate message with string
IF (numToDisplay% = LEN(midChar$)) THEN
PRINT numToDisplay%; "characters displayed: "; midChar$
ELSE
PRINT numToDisplay%; "characters requested,";
PRINT LEN(midChar$); "displayed: "; midChar$
END IF